<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/web/header.jsp"%>
<title>Insert title here</title>
</head>
<body>
<fieldset class="layui-elem-field" style="margin: 25px;">
		<legend>信息维护-添加信息</legend>
		<div class="layui-field-box">
			<form class="layui-form" lay-filter="formE" method="post">
				<div class="layui-form-item">
					<label class="layui-form-label">项目编号</label>
					<div class="layui-input-block">
						<input type="text" name="code" lay-verify="required"
							style="width: 200px;" placeholder="请输入项目编号" autocomplete="off"
							class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">员工姓名</label>
					<div class="layui-input-inline">
						<select name="codeEmp"></select>
					</div>
				</div>
				
			
				<div style="width: 68%; margin: auto;">
					<div class="layui-input-inline" >
						<input type="button" class="layui-btn"  lay-submit
							lay-filter="updEmp" value="确定">
					</div>
					<div class="layui-input-inline">
						<input type="button" class="layui-btn" onclick="closeThis()"
							value="取消">
					</div>
					<div class="layui-input-inline">
						<input type="reset" class="layui-btn layui-btn-primary">
					</div>
				</div>
				<input type="hidden" name="action" value="updEmp">
			</form>
		</div>

	</fieldset>
	<script type="text/javascript">
	var code=<%=request.getParameter("code")%>
	initSel();
	function initSel(){
		ajax("/employee",{action:"list"},'json',function(data){
// 			console.log(data)
			var option="<option value=''>"+"请选择员工编号"+"</option>"
			$.each(data,function(){
				option+="<option value='"+this.code+"'>"+this.name+"</option>"
			})
			$("select[name='codeEmp']").html(option);
			form.render();
			init();
		})
	}

	function init(){
 	ajax('/project',{action:"get",code:code},'json',function(data){
 		form.val("formE",{code:data.code,codeEmp:data.codeEmp})
 	})
	}
	formSubmit("/project","submit(updEmp)",'text',function(data){
// 		console.log(data)
		if(data==1){
			layer.msg("分配项目成功",{time:1000},closeThis)
		}else{
			layer.msg("分配失败")
		}
	})
	</script>
</body>
</html>